package com.yupi.yupicturebackend.model.enums;

import cn.hutool.core.util.ObjUtil;

import lombok.Getter;

@Getter
public enum UserRoleEnum {
    USER("用户","user"),
    ADMIN("管理员","admin"),
    VIP("会员","vip");
    private final String text;
    private final String value;

    UserRoleEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 根据给定的字符串值获取对应的UserRoleEnum枚举实例
     * @param value
     * @return
     */
    public static UserRoleEnum getEnumByValue(String value){
        if (ObjUtil.isEmpty(value)){
            return null;
        }
        for (UserRoleEnum anEnum: UserRoleEnum.values()){
            if (anEnum.value.equals(value)){
                return anEnum;
            }
        }
        return null;
    }
}


//    public static void main(String[] args) {
//        for (UserRoleEnum anEnum: UserRoleEnum.values()){
//            System.out.println(anEnum.getText()+":"+anEnum.getValue());
//
//            }
//        }
//
//    }


